# zarfy
# Builds from https://github.com/puppylinux-woof-CE/petbuilds
# File auto generated by ./mk_petbuild.sh. Edit as necessary.

. ../func
. ../build.conf

URL=http://downloads.sourceforge.net/project/zarfy/zarfy/zarfy%200.1.0
PKG=zarfy
VER=0.1.0
COMP=tar.bz2
DESC="A graphical tool for controlling multiple monitors using xrandr"
DEPS=
CAT=Setup
DESKTOP=zarfy.desktop
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
# comment these 2 below if you use a custom package() function
[ -f "$DESKTOP" ] || DESKTOP=not
[ -z "$DEPS" ] && DEPS=not

ARCH=$(uname -m)
case $ARCH in # set in build.conf
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

patch_me() {
	(cd ${PKG}-${VER}
	for i in ../*.patch; do
	echo applying $i
	sleep 1
	patch -p0 < $i
	done)
}

build() {
	cd ${PKG}-${VER}
	LDFLAGS="-lm -lX11" \
	./configure --prefix=/usr \
				--libdir=/usr/${LIBDIR} \
				--libexec=/usr/lib \
				--enable-shared=yes \
				--enable-static=no \
				--enable-debug=no
	make || exit 1
	make DESTDIR=${CWD}/${PKG}-install install
	# autostart stuff
	mkdir -p ${CWD}/${PKG}-install/root/.config/autostart
	cat > ${CWD}/${PKG}-install/root/.config/autostart/zarfy-start.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Type=Application
NoDisplay=true
Name=zarfy-start
Exec=zarfy-start
EOL
	chmod 644 ${CWD}/${PKG}-install/root/.config/autostart/zarfy-start.desktop
	cat > ${CWD}/${PKG}-install/usr/bin/zarfy-start << EOF
#!/bin/sh
[ -d "\$HOME/.zarfy" ] && zarfy -l
EOF
	chmod 755 ${CWD}/${PKG}-install/usr/bin/zarfy-start
	# end autostart
	cd -
}

# main
retrieve ${PKG}-${VER}.${COMP}
extract ${PKG}-${VER}.${COMP}
patch_me
build
package_std $PKG $VER $ARCH $DESKTOP "$DESC" $DEPS $CAT
